﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GPSTrackingLogCustom
{
    public class NotificationsLog
    {
        public enum MQType
        {
            Email,
            SMS,
            Information,
            Error,
            Warning
        }

        /// <summary>
        /// Logs an informational MQ message
        /// </summary>
        /// <param name="GPSID">GPS Device ID</param>
        /// <param name="mQType">MQ Type</param>
        /// <param name="message">message</param>              
        public static void Info(string message)
        {
            GPSTrackingServerDB.Entities.NotificationsLog LogEntity = new GPSTrackingServerDB.Entities.NotificationsLog();
            LogEntity.Imei = "N/A";
            LogEntity.DateTime = DateTime.Now;
            LogEntity.Type = MQType.Information.ToString();
            LogEntity.Message = message;

            GPSTrackingServerDB.Data.DataRepository.NotificationsLogProvider.Insert(LogEntity);
        }

        /// <summary>
        /// Logs an informational MQ message
        /// </summary>
        /// <param name="message">message</param>              
        public static void Info(string imei, string message)
        {
            GPSTrackingServerDB.Entities.NotificationsLog LogEntity = new GPSTrackingServerDB.Entities.NotificationsLog();
            LogEntity.Imei = imei;
            LogEntity.DateTime = DateTime.Now;
            LogEntity.Type = MQType.Information.ToString();
            LogEntity.Message = message;

            GPSTrackingServerDB.Data.DataRepository.NotificationsLogProvider.Insert(LogEntity);
        }

        /// <summary>
        /// Logs an Warning MQ message
        /// </summary>
        /// <param name="message">message</param>              
        public static void Warning(string message)
        {
            GPSTrackingServerDB.Entities.NotificationsLog LogEntity = new GPSTrackingServerDB.Entities.NotificationsLog();
            LogEntity.Imei = "N/A";
            LogEntity.DateTime = DateTime.Now;
            LogEntity.Type = MQType.Warning.ToString();
            LogEntity.Message = message;

            GPSTrackingServerDB.Data.DataRepository.NotificationsLogProvider.Insert(LogEntity);
        }

        /// <summary>
        /// Logs an Error MQ message
        /// </summary>
        /// <param name="message">message</param>              
        public static void Error(string message)
        {
            GPSTrackingServerDB.Entities.NotificationsLog LogEntity = new GPSTrackingServerDB.Entities.NotificationsLog();
            LogEntity.Imei = "N/A";
            LogEntity.DateTime = DateTime.Now;
            LogEntity.Type = MQType.Error.ToString();
            LogEntity.Message = message;

            GPSTrackingServerDB.Data.DataRepository.NotificationsLogProvider.Insert(LogEntity);
        }
    }
}
